﻿using System;
using System.Collections.Generic;
using System.Text;

using Octopus.Logging;
using Octopus.Logging.Impl.Text;
using System.Diagnostics;

namespace Octopus.Logging.Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
            
                //LogManager.Init(@"config\");

                //获取日志器
                ILogger logger = LogManager.GetLogger("LoggingDemo/UT");
                //使用日志器
                logger.Info("开始测试配置的业务日志", LogHelper.BuildContext("今天温度", 38, "当前时戳", new TimeSpan(1, 1, 1)));
                logger.Error("出错了", new ApplicationException("故意异常"));
                logger.Info("完成测试配置的业务日志");

                //获取另一个业务日志器
                ILogger loggerMin = LogManager.GetLogger("loggingMin");
                loggerMin.Warning("记录其他业务日志");

                Test(loggerMin);
                Console.WriteLine("完成");
            }
            catch (Exception err)
            {
                Console.WriteLine(err.ToString());
            }
            finally
            {
            }

            if (Console.ReadLine() == "c") { Main(null); }
        }

        static void Test(ILogger log)
        {
            DateTime now = DateTime.Now;
            for (int i = 0; i < 1000; i++)
            {
                log.Warning("开始测试配置的业务日志", LogHelper.BuildContext("今天温度", 38, "当前时戳", new TimeSpan(1, 1, 1)));
            }
            log.Info((DateTime.Now - now).ToString());
        }
    }

}
